package com.black.play.util;

import java.util.Random;

/**
 * @author ylx
 */
public class ArrayUtil
{
    public static final Random RANDOM = new Random();

    /**
     * Shuffles the given array.
     *
     * @param array the array to shuffle
     */
    public static void shuffle(int[] array)
    {
        for (int i = array.length - 1; i > 0; i--)
        {
            int randomIndex = RANDOM.nextInt(i + 1);
            int temp = array[i];
            array[i] = array[randomIndex];
            array[randomIndex] = temp;
        }
    }
}
